package com.shop.dingdongshoppingapi.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.shop.dingdongshoppingapi.dto.HistoryAddDto;
import com.shop.dingdongshoppingapi.entity.History;
import com.shop.dingdongshoppingapi.service.intf.HistoryService;
import com.shop.dingdongshoppingapi.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/api/history/")
@Api(tags = "搜索历史记录")
@CrossOrigin
public class HistoryController {
    @Resource
    private HistoryService historyService;

    @GetMapping("all.do")
    @ApiOperation(value = "查询所有历史记录")
    public R all(int uid){
        return historyService.queryByUid(uid);
    }

    @PostMapping("save.do")
    @ApiOperation(value = "添加历史记录")
    public R save(@RequestBody HistoryAddDto historyAddDto, HttpServletRequest request){
        return historyService.save(historyAddDto, 1);
    }
}
